unit mqc;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, base, StdCtrls, Buttons, ExtCtrls, drawQC, ComCtrls, RzButton,
  ActnList;

type
  Tmqcfrm = class(Tbasefrm)
    palgd: TPanel;
    DateTimePicker1: TDateTimePicker;
    Label1: TLabel;
    RzBitBtn1: TRzBitBtn;
    RzBitBtn2: TRzBitBtn;
    RzBitBtn3: TRzBitBtn;
    RzBitBtn4: TRzBitBtn;
    ActionList1: TActionList;
    Action1: TAction;
    Action2: TAction;
    Action3: TAction;
    Action4: TAction;
    procedure palgdResize(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure RzBitBtn1Click(Sender: TObject);
    procedure RzBitBtn2Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure DateTimePicker1Change(Sender: TObject);
    procedure RzBitBtn4Click(Sender: TObject);
    procedure RzBitBtn3Click(Sender: TObject);
    procedure Action1Execute(Sender: TObject);
    procedure Action2Execute(Sender: TObject);
    procedure Action3Execute(Sender: TObject);
    procedure Action4Execute(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    palArr:Array[0..5] of TPanel;
    drawQCArr:array[0..5] of TdrawQcfrm;
    rfidArr:TStringList;
    rfidIndex:integer;
    procedure qcRefresh(Index:integer);
  end;

var
  mqcfrm: Tmqcfrm;

implementation

{$R *.dfm}

uses
  includefile, dbmodule;

procedure Tmqcfrm.qcRefresh(Index:integer);
var
  dt:TDateTime;
  I:integer;
begin
  //Exsleep(10);
  dt:=DateTimePicker1.DateTime;
  dbmodulefrm.getRcdRfidByDate(rfidArr,dt);
  for I:=0 to 5 do begin
    if (Index+I>=rfidArr.Count) then exit; 
    drawQCArr[I].getChatData(rfidArr.Strings[Index+I],dt);
  end;
end;

procedure Tmqcfrm.palgdResize(Sender: TObject);
var
  wd,ht:integer;
  I:integer;
begin
  wd:=palgd.Width div 3;
  ht:=palgd.Height div 2;
  for i:=0 to 5 do begin
    palArr[I].Width:=wd;
    palArr[I].Height:=ht;
    palArr[I].Top:= (I div 3)*ht;
    palArr[I].Left:= (I mod 3)*wd;
  end;
end;

procedure Tmqcfrm.FormCreate(Sender: TObject);
var
  I:integer;
begin
  inherited;
  for I:=0 to ComponentCount-1 do begin
    if Components[I] is TLabel then begin
      if 0<>TLabel(Components[I]).Tag then
        TLabel(Components[I]).Caption:=
                GetCaption(name,TLabel(Components[I]).Tag);
    end;
    if Components[I] is TRzBitBtn then begin
      if 0<>TRzBitBtn(Components[I]).Tag then
        TRzBitBtn(Components[I]).Caption:=
                GetCaption(name,TRzBitBtn(Components[I]).Tag);
    end;
  end;
  rfidIndex:=0;
  rfidArr:=TStringList.Create;
  for I:=0 to 5 do begin
    palArr[I]:=TPanel.Create(Application);
    palArr[I].Parent:=palgd;
    drawQCArr[I]:=TdrawQcfrm.Create(Application);
    drawQCArr[I].Name:='s'+inttostr(I);
    drawQCArr[I].Parent:=palArr[I];
    palArr[I].Show;
    drawQCArr[I].Show;
  end;
end;

procedure Tmqcfrm.RzBitBtn1Click(Sender: TObject);
begin
  inherited;
  rfidIndex:=0;
  DateTimePicker1.Date:=DateTimePicker1.Date-1;
  qcRefresh(rfidIndex);
end;

procedure Tmqcfrm.RzBitBtn2Click(Sender: TObject);
begin
  inherited;
  rfidIndex:=0;
  DateTimePicker1.Date:=DateTimePicker1.Date+1;
  qcRefresh(rfidIndex);
end;

procedure Tmqcfrm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  rfidArr.Free;
  inherited;
end;

procedure Tmqcfrm.DateTimePicker1Change(Sender: TObject);
begin
  inherited;
  rfidIndex:=0;
  qcRefresh(rfidIndex);
end;

procedure Tmqcfrm.RzBitBtn4Click(Sender: TObject);
begin
  inherited;
  rfidIndex:=rfidIndex-6;
  if rfidIndex<0 then rfidIndex:=0;
  qcRefresh(rfidIndex)
end;

procedure Tmqcfrm.RzBitBtn3Click(Sender: TObject);
begin
  inherited;
  rfidIndex:=rfidIndex+6;
  qcRefresh(rfidIndex)
end;

procedure Tmqcfrm.Action1Execute(Sender: TObject);
begin
  inherited;
  RzBitBtn1Click(self);
end;

procedure Tmqcfrm.Action2Execute(Sender: TObject);
begin
  inherited;
  RzBitBtn2Click(self);
end;

procedure Tmqcfrm.Action3Execute(Sender: TObject);
begin
  inherited;
  RzBitBtn4Click(self);
end;

procedure Tmqcfrm.Action4Execute(Sender: TObject);
begin
  inherited;
  RzBitBtn3Click(self);
end;

end.
